﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace MvcShop.Models
{
    [MetadataType(typeof(UserInfoMetadata))]
    public partial class UserInfo
    { }

    public class UserInfoMetadata
    {
        [Required(ErrorMessage="用户Id为空。")]
        public int UserId { get; set; }

        [DisplayName("姓名")]
        [Required(ErrorMessage = "姓名不能为空。")]
        [StringLength(50, ErrorMessage = "姓名长度必须小于50位。")]
        public string Name { get; set; }

        [DisplayName("性别")]
        [Required(ErrorMessage = "性别不能为空。")]
        [StringLength(2, ErrorMessage = "性别长度必须小于2位。")]
        public string Sex { get; set; }

        [DisplayName("身分证号")]
        public string Identity { get; set; }

        [DisplayName("省")]
        [StringLength(20, ErrorMessage = "省份长度必须小于20位。")]
        public string Region { get; set; }

        [DisplayName("市")]
        [StringLength(20, ErrorMessage = "城市长度必须小于20位。")]
        public string City { get; set; }

        [DisplayName("区")]
        [StringLength(20, ErrorMessage = "地区长度必须小于20位。")]
        public string Area { get; set; }

        [DisplayName("手机")]
        [Required(ErrorMessage = "手机不能为空。")]
        [RegularExpression(@"^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$", ErrorMessage = "请输入正确的手机号码.")]
        public string Mobile { get; set; }

        [DisplayName("电话")]
        public string Phone { get; set; }

        [DisplayName("您的职务")]
        [StringLength(50, ErrorMessage = "职务长度必须小于50位。")]
        public string YourJobs { get; set; }

        [DisplayName("公司名称")]
        [StringLength(50, ErrorMessage = "公司名称长度必须小于50位。")]
        public string CompanyName { get; set; }

        [DisplayName("公司地址")]
        [StringLength(225, ErrorMessage = "公司地址长度必须小于225位。")]
        public string CompanyAddress { get; set; }

        [DisplayName("电子邮件")]
        [RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "请输入正确的邮件地址.")]
        public string Email { get; set; }

        [DisplayName("邮编")]
        [Required(ErrorMessage = "邮编不能为空。")]
        [RegularExpression(@"^[1-9]\d{5}$", ErrorMessage = "请输入正确的邮编地址。")]
        public int Postalcode { get; set; }
    }
}
